import java.io.File;
import java.io.FileFilter;

public class Test09 {
    public static void main(String[] args) {
        File f=new File("D:\\aaa");
        File[] arr=f.listFiles(new FileFilter(){
            @Override
            public boolean accept(File pathname){
                return pathname.isFile()&&pathname.getName().endsWith(".txt");
            }
        });
        for(File file:arr){
            System.out.println(file);
        }
    }
}
